package com.packagetracker.providers;

import java.util.HashMap;

import android.content.UriMatcher;
import android.net.Uri;
import android.provider.BaseColumns;

public final class TrackerProviderSetup {
	
	public static final String URI = "com.packagetracker.providers.TrackerProvider";
	public static final String DATABASE_NAME = "package.tracker.db";
	public static final int DATABASE_VERSION = 1;
	public static final UriMatcher MATCHER;
	
	private TrackerProviderSetup() {}
	
	static {
		MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
		MATCHER.addURI(TrackerProviderSetup.URI, Numbers.TABLE_NAME, Numbers.TABLE);
		MATCHER.addURI(TrackerProviderSetup.URI, Numbers.TABLE_NAME + "/*", Numbers.TABLE_NUMBER);
		MATCHER.addURI(TrackerProviderSetup.URI, Settings.TABLE_NAME, Settings.TABLE);
	}
	
	public static String getIdColumnName() {
		return "_id";
	}
	
	public static final class Numbers implements BaseColumns {
		private Numbers() {}
		
		public static final String TABLE_NAME = "numbers";
		public static final int TABLE = 1;
		public static final int TABLE_NUMBER = 2;
		public static final Uri NUMBERS_URI = Uri.parse("content://" + URI + "/" + TABLE_NAME);
		public static final Uri NUMBER_URI = Uri.parse("content://" + URI + "/" + TABLE_NAME + "/" );
		public static final String CARRIER = "carrier";
		public static final String NUMBER = "number";
		public static final HashMap<String, String> PROJECTION = new HashMap<String, String>();
		
		static {
			PROJECTION.put(_ID, _ID);
			PROJECTION.put(CARRIER, CARRIER);
			PROJECTION.put(NUMBER, NUMBER);
		}
		
		public static String getNullColumnHack() {
			return NUMBER;
		}
	}
	
	public static final class Settings implements BaseColumns {
		private Settings() {}
		
		public static final String TABLE_NAME = "settings";
		public static final int TABLE = 3;
		public static final Uri CONTENT_URI = Uri.parse("content://" + URI + "/" + TABLE_NAME);
		public static final String MAP_TYPE = "map_type";
		public static final HashMap<String, String> PROJECTION = new HashMap<String, String>();
		
		static {
			PROJECTION.put(MAP_TYPE, MAP_TYPE);
		}
		
		public static String getNullColumnHack() {
			return MAP_TYPE;
		}
	}
	
}